import { store } from '@/store'
import { defineStore } from 'pinia'
import { useCache } from '@/hooks/web/useCache'
const { wsCache } = useCache()

export const useCaseStore = defineStore('test-plan', {
  state: () => ({
    cases: JSON.parse(wsCache.get('cases'))
  }),
  getters: {
    getCases(): object[] {
      return this.cases
    }
  },
  actions: {
    setCases(data) {
      wsCache.set('cases', JSON.stringify(data))
      this.cases = data
    }
  }
})

export const useCaseStoreWithOut = () => {
  return useCaseStore(store)
}
